package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.PensionServices;
import com.ruoyi.system.service.IPensionServicesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 服务申请Controller
 * 
 * @author ruoyi
 * @date 2021-07-09
 */
@RestController
@RequestMapping("/system/services")
public class PensionServicesController extends BaseController
{
    @Autowired
    private IPensionServicesService pensionServicesService;

    /**
     * 查询服务申请列表
     */
//    @PreAuthorize("@ss.hasPermi('system:services:list')")
    @GetMapping("/list")
    public TableDataInfo list(PensionServices pensionServices)
    {
        startPage();
        List<PensionServices> list = pensionServicesService.selectPensionServicesList(pensionServices);
        return getDataTable(list);
    }

    /**
     * 导出服务申请列表
     */
//    @PreAuthorize("@ss.hasPermi('system:services:export')")
    @Log(title = "服务申请", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PensionServices pensionServices)
    {
        List<PensionServices> list = pensionServicesService.selectPensionServicesList(pensionServices);
        ExcelUtil<PensionServices> util = new ExcelUtil<PensionServices>(PensionServices.class);
        return util.exportExcel(list, "services");
    }

    /**
     * 获取服务申请详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:services:query')")
    @GetMapping(value = "/{pId}")
    public AjaxResult getInfo(@PathVariable("pId") Long pId)
    {
        return AjaxResult.success(pensionServicesService.selectPensionServicesById(pId));
    }

    /**
     * 新增服务申请
     */
//    @PreAuthorize("@ss.hasPermi('system:services:add')")
    @Log(title = "服务申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PensionServices pensionServices)
    {
        return toAjax(pensionServicesService.insertPensionServices(pensionServices));
    }

    /**
     * 修改服务申请
     */
//    @PreAuthorize("@ss.hasPermi('system:services:edit')")
    @Log(title = "服务申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PensionServices pensionServices)
    {
        return toAjax(pensionServicesService.updatePensionServices(pensionServices));
    }

    /**
     * 删除服务申请
     */
//    @PreAuthorize("@ss.hasPermi('system:services:remove')")
    @Log(title = "服务申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pIds}")
    public AjaxResult remove(@PathVariable Long[] pIds)
    {
        return toAjax(pensionServicesService.deletePensionServicesByIds(pIds));
    }
}
